package com.example.bledemo.tool;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;

public class SPUtil {


    private static final String TAG = "SP";

    public static final String LoginOutTime="login_pit_time";
    public static final String MAC="mac";
    public static final String IP="ip";
    public static final String PORT="port";
    @SuppressLint("StaticFieldLeak")
    private static Context mContext;

    public static boolean getBooleanValue(String paramString) {
        return mContext.getSharedPreferences(TAG, 0).getBoolean(paramString, false);
    }

    public static float getFloatValue(String paramString) {
        return mContext.getSharedPreferences(TAG, 0).getFloat(paramString, 0.0F);
    }

    public static int getIntValue(String paramString) {
        return mContext.getSharedPreferences(TAG, 0).getInt(paramString, 0);
    }

    public static String getStringValue(String paramString) {
        return mContext.getSharedPreferences(TAG, 0).getString(paramString, "");
    }

    public static String getStringValue(String paramString, String defaultString) {
        return mContext.getSharedPreferences(TAG, 0).getString(paramString, defaultString);
    }

    public static void initSP(Context paramContext) {
        if (mContext == null) {
            mContext = paramContext.getApplicationContext();
        }
    }

    public static void putBooleanValue(String paramString, boolean paramBoolean) {
        SharedPreferences.Editor localEditor = mContext.getSharedPreferences(TAG, 0).edit();
        localEditor.putBoolean(paramString, paramBoolean);
        localEditor.commit();
    }

    public static void putFloatValue(String paramString, float paramFloat) {
        SharedPreferences.Editor localEditor = mContext.getSharedPreferences(TAG, 0).edit();
        localEditor.putFloat(paramString, paramFloat);
        localEditor.commit();
    }

    public static void putIntValue(String paramString, int paramInt) {
        SharedPreferences.Editor localEditor = mContext.getSharedPreferences(TAG, 0).edit();
        localEditor.putInt(paramString, paramInt);
        localEditor.commit();
    }

    public static void putStringValue(String paramString1, String paramString2) {
        SharedPreferences.Editor localEditor = mContext.getSharedPreferences(TAG, 0).edit();
        localEditor.putString(paramString1, paramString2);
        localEditor.commit();
    }

    public static void remove(String paramString) {
        SharedPreferences.Editor localEditor = mContext.getSharedPreferences(TAG, 0).edit();
        localEditor.remove(paramString);
        localEditor.commit();
    }
}
